package plugin_trait;

import java.util.Random;
import java.util.Scanner;

import donnees.Village;

import interfaceJeu.ITraitement;

public class TraitementDefaut implements ITraitement {
	private int propOr;
	private int propNour;
	
	@Override
	public void prioriserOr(Village v) {
		Random rand = new Random();
		this.propOr = rand.nextInt(100 - (50) + 1) + (50);
		this.propNour = 100 - this.propOr;
		this.traitement_tour_de_jeu(v);
	}

	@Override
	public void prioriserNourriture(Village v) {
		Random rand = new Random();
		this.propNour = rand.nextInt(100 - (50) + 1) + (50);
		this.propOr = 100 - this.propOr;
		this.traitement_tour_de_jeu(v);
	}

	@Override
	public void traitement_tour_de_jeu(Village v) {
		v.setOr((int) (ret_or_gen_jeu(v.ret_cap_or())*(this.propOr/100)  + v.getOr()) );
		v.setNourriture((int) (ret_nourriture_gen_jeu(v.ret_cap_nourriture())*(this.propNour/100) + v.getNourriture()));
		nourrirVillage(v);
	}
	
	
	public void nourrirVillage(Village v){
		v.setNourriture(v.getNourriture() - v.getListVillageois().size()*5);
	}
	
	public int ret_or_gen_jeu(int max){
		int or = 0;
		Random rand_or = new Random();
		or = rand_or.nextInt(max - (max-20) + 1) + (max-20);
		return or;
	}
	
	public int ret_nourriture_gen_jeu(int max){
		int nourriture = 0;
		Random rand_nourriture = new Random();
		nourriture = rand_nourriture.nextInt(max - (max-20) + 1) + (max-20);
		return nourriture;
	}

}
